package com.warm.base.design.b_memento.mult;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date: 2019/11/28 10:25
 * @Author: LChuang
 * @Description:
 */
public class MCaretaker {

    private MOriginator mo;

    private List<MMemento> mMementos = new ArrayList<>();

    public MCaretaker(MOriginator mo){
        this.mo = mo;
    }

    public void createMMemento(){
        MMemento mMemento = mo.createMemento();
        mMementos.add(mMemento);
    }

    public void restoreMMemento(int index){
        MMemento mMemento = mMementos.get(index);
        mo.restoreMMemento(mMemento);
    }

    public void removeMMemento(int index){
        mMementos.remove(index);
    }
}
